<template>
  <el-table :data="tableData" style="width: 100%; margin-bottom: 20px" row-key="id" border default-expand-all>
    <el-table-column label="2C售后-聚水潭" align="center">
      <el-table-column width="200" prop="confirmDate" label="最后确认日期" align="center" />
      <el-table-column width="200" prop="shopName" label="店铺名称" align="center" />
      <el-table-column width="300" prop="code" label="物料编码" align="center" />
      <el-table-column width="200" prop="count" label="求和项:申请数量" align="center" />
    </el-table-column>
    <el-table-column prop="salesKingdee" label="2C售后-金蝶" align="center" />
    <el-table-column width="200" prop="diff" label="差异" align="center" />
  </el-table>
</template>

<script setup lang="ts">
const tableData = ref([]);

// 模拟请求方法
const fetchData = () => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        data: [
          {
            id: 1,
            confirmDate: '2024-09-12',
            shopName: '天猫',
            code: 'HC120100000000-CN',
            count: '2',
            salesKingdee: 'HC120100000000-CN',
            diff: '2',
            children: [
              {
                id: '1-1',
                confirmDate: '2024-09-12',
                shopName: '天猫',
                code: 'HC120100000000-CN',
                count: '2',
                salesKingdee: 'HC120100000000-CN',
                diff: '2',
                children: [
                  {
                    id: '1-1-1',
                    confirmDate: '2024-09-12',
                    shopName: '京东',
                    code: 'HC120100000000-CN',
                    count: '2',
                    salesKingdee: 'HC120100000000-CN',
                    diff: '2'
                  },
                  {
                    id: '1-1-2',
                    confirmDate: '2024-09-12',
                    shopName: '京东',
                    code: 'HC120100000000-CN',
                    count: '2',
                    salesKingdee: '',
                    diff: ''
                  },
                  {
                    id: '1-1-3',
                    confirmDate: '2024-09-12',
                    shopName: '京东',
                    code: 'HC120100000000-CN',
                    count: '2',
                    salesKingdee: '',
                    diff: ''
                  },
                  {
                    id: '1-1-4',
                    confirmDate: '2024-09-12',
                    shopName: '京东',
                    code: 'HC120100000000-CN',
                    count: '2',
                    salesKingdee: '',
                    diff: ''
                  }
                ]
              }
            ]
          }
        ]
      });
    }, 1000); // 模拟延迟1秒
  });
};

onMounted(async () => {
  try {
    const res = await fetchData();
    tableData.value = res.data;
    console.log('tableData', tableData.value);
  } catch (error) {
    console.error('请求失败:', error);
  }
});
</script>
<style scoped></style>
